#include "ClickableArea.h"


ClickableArea::ClickableArea(const sf::Vector2i& upperLeft, const sf::Vector2i& bottomRight): upperLeft(upperLeft), bottomRight(bottomRight)
{
}

ClickableArea::~ClickableArea(){
}

const sf::Vector2i& ClickableArea::getUpperLeft() const
{
    return upperLeft;
}

const sf::Vector2i&  ClickableArea::getBottomRight() const
{
    return bottomRight;
}

void ClickableArea::setUpperLeft( const sf::Vector2i& c)
{
    upperLeft=c;
}

void ClickableArea::setBottomRight( const sf::Vector2i& c)
{
    bottomRight=c;
}

// This function is called when the player left click to somewhere.
bool ClickableArea::processMouseEvent(const sf::Vector2i& c, sf::RenderWindow& window)
{
    //Check if player clicked to that object or not
    if(c.x > upperLeft.x
       && c.x < bottomRight.x
       && c.y > upperLeft.y
       && c.y < bottomRight.y)
        {   //Call on-click effect
            onClick(window);
            return true;
        }
    return false;
}

void ClickableArea::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
	target.draw(sprite, states);
}